package hd3.wordcount;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @Author: laoyu
 * @Date: 2020/6/4 10:59
 * @Description:
 */
public class WcMapper extends Mapper<LongWritable, Text, Text, LongWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //接收数据
        String line = value.toString();
        //切分数据
        String[] words = line.split(" ");
        //循环
        for (String s : words) {
            System.out.println("map:"+s);
            context.write(new Text(s),new LongWritable(1));
        }

    }
}
